<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@page import="java.lang.System"%>
<%@page import="java.util.Calendar"%>
<%!
	// Get date from the current time to be used as default values.
	Calendar currentTime = Calendar.getInstance();
	// Set output format to two digits.
	java.text.DecimalFormat nft = new java.text.DecimalFormat("#00.###");  
	
	public String getMonth(int month)
	{
		switch (month) {
			case Calendar.JANUARY: return "January";
			case Calendar.FEBRUARY: return "February";
			case Calendar.MARCH: return "March";
			case Calendar.APRIL: return "April";
			case Calendar.MAY: return "May";
			case Calendar.JUNE: return "June";
			case Calendar.JULY: return "July";
			case Calendar.AUGUST: return "August";
			case Calendar.SEPTEMBER: return "September";
			case Calendar.OCTOBER: return "October";
			case Calendar.NOVEMBER: return "November";
			case Calendar.DECEMBER: return "December";
		}
		return null;
	}
	
	public String getDaysInMonth(int month)
	{
		switch (month) {
			case Calendar.JANUARY: return "January";
			case Calendar.FEBRUARY: return "February";
			case Calendar.MARCH: return "March";
			case Calendar.APRIL: return "April";
			case Calendar.MAY: return "May";
			case Calendar.JUNE: return "June";
			case Calendar.JULY: return "July";
			case Calendar.AUGUST: return "August";
			case Calendar.SEPTEMBER: return "September";
			case Calendar.OCTOBER: return "October";
			case Calendar.NOVEMBER: return "November";
			case Calendar.DECEMBER: return "December";
		}
		return null;
	}
%>

<HTML>
	<head>
		<link rel="stylesheet" type="text/css" href="css/AllPages.css">
		<link rel="stylesheet" type="text/css" href="css/Restaurant.css">
	</head>

	<!-- Generate list of available table sizes -->
	

	<body>
	<style type="text/css">
	td{
		width:300px
	}
	tr{
		height:50px
	}
	</style>

		<html:form action="ToReservationAccepted.do">
			<table>
				<tr>
					<td colspan=2 align="center">
						<font size="24">
							Enter Reservation Information
						</font>
					</td>
				</tr>
				<tr>
					<td align="right">
						<b>Name:</b>
					</td>
					<td>
						<html:text name="ReservationForm" property="name" />
					</td>
				</tr>
				<tr>
					<td align="right">
						<b>Phone Number:</b>
					</td>
					<td>
						<html:text name="ReservationForm" property="phoneNumber" />
					</td>
				</tr>
				<tr>
					<td align="right">
						<b>Number of Seats:</b>
					</td>
					<td>
						<html:text name="ReservationForm" property="numOfSeats"/>
					</td>
				</tr>
				<%
					if (currentTime != null)
						currentTime.set(Calendar.MINUTE,((int)currentTime.get(Calendar.MINUTE)/15) * 15);
	
					nft.setDecimalSeparatorAlwaysShown(false);  	
	
				%>
				<tr colspan=2>
					<td align="right" colspan=1>
						<b>Reservation Search Start Time:</b>
					</td>
					<td>
					<table>
						<td>
							<html:select name="ReservationForm" property="startHour" value="<%=\"\"+nft.format(currentTime.get(Calendar.HOUR_OF_DAY)%12)%>">
								<html:option value="12">12</html:option>
								<html:option value="01">01</html:option>
								<html:option value="02">02</html:option>
								<html:option value="03">03</html:option>
								<html:option value="04">04</html:option>
								<html:option value="05">05</html:option>
								<html:option value="06">06</html:option>
								<html:option value="07">07</html:option>
								<html:option value="08">08</html:option>
								<html:option value="09">09</html:option>
								<html:option value="10">10</html:option>
								<html:option value="11">11</html:option>
							</html:select>
						</td>
						<td width=1px>
						<strong><b>:</b></strong>
						</td>
						<td>
							<html:select name="ReservationForm" property="startMinute" value="<%=\"\"+nft.format(currentTime.get(Calendar.MINUTE))%>">
								<html:option value="00">00</html:option>
								<html:option value="15">15</html:option>
								<html:option value="30">30</html:option>
								<html:option value="45">45</html:option>
							</html:select>
						</td>
						<td>
							<html:select name="ReservationForm" property="startAM" value="<%=(currentTime.get(Calendar.HOUR_OF_DAY)>=12)?\"PM\":\"AM\"%>">
								<html:option value="AM">AM</html:option>
								<html:option value="PM">PM</html:option>
							</html:select>
						</td>
						<td>
							<html:select name="ReservationForm" property="startMonth" value="<%=\"\"+(currentTime.get(Calendar.MONTH))%>">
								<%
								String month;
								for (int i = 0; i < 12; i++)
								{
									month = getMonth(i);%>
									<html:option value="<%=\"\"+i%>"><%=month%></html:option>
								<%}%>
							</html:select>
						</td>
						<td>
							<html:select name="ReservationForm" property="startDay" value="<%=\"\"+currentTime.get(Calendar.DAY_OF_MONTH)%>">
								<%
								for (int i = 0; i < 31; i++)
								{%>
									<html:option value="<%=\"\"+i%>"><%=i%></html:option>
								<%}%>
							</html:select>
						</td>
						<td>
							<html:select name="ReservationForm" property="startYear" value="<%=\"\"+currentTime.get(Calendar.YEAR)%>">
								<%
								for (int i = 0; i < 5; i++)
								{%>
									<html:option value="<%=\"\"+(currentTime.get(Calendar.YEAR)+i)%>"><%=(currentTime.get(Calendar.YEAR)+i)%></html:option>
								<%}%>
							</html:select>
						</td>
					</table>
					</td>
				</tr>
				<tr colspan=2>
					<td align="right" colspan=1>
						<b>Reservation Search End Time:</b>
					</td>
					<td>
					<table>
						<td>
							<html:select name="ReservationForm" property="endHour" value="<%=\"\"+nft.format(currentTime.get(Calendar.HOUR_OF_DAY)%12)%>">
								<html:option value="12">12</html:option>
								<html:option value="01">01</html:option>
								<html:option value="02">02</html:option>
								<html:option value="03">03</html:option>
								<html:option value="04">04</html:option>
								<html:option value="05">05</html:option>
								<html:option value="06">06</html:option>
								<html:option value="07">07</html:option>
								<html:option value="08">08</html:option>
								<html:option value="09">09</html:option>
								<html:option value="10">10</html:option>
								<html:option value="11">11</html:option>
							</html:select>
						</td>
						<td width=1px>
						<strong><b>:</b></strong>
						</td>
						<td>
							<html:select name="ReservationForm" property="endMinute" value="<%=\"\"+nft.format(currentTime.get(Calendar.MINUTE))%>">
								<html:option value="00">00</html:option>
								<html:option value="15">15</html:option>
								<html:option value="30">30</html:option>
								<html:option value="45">45</html:option>
							</html:select>
						</td>
						<td>
							<html:select name="ReservationForm" property="endAM" value="<%=(currentTime.get(Calendar.HOUR_OF_DAY)>=12)?\"PM\":\"AM\"%>">
								<html:option value="AM">AM</html:option>
								<html:option value="PM">PM</html:option>
							</html:select>
						</td>
						<td>
							<html:select name="ReservationForm" property="endMonth" value="<%=\"\"+currentTime.get(Calendar.MONTH)%>">
								<%
								String month;
								for (int i = 0; i < 12; i++)
								{
									month = getMonth(i);%>
									<html:option value="<%=\"\"+i%>"><%=month%></html:option>
								<%}%>
							</html:select>
						</td>
						<td>
							<html:select name="ReservationForm" property="endDay" value="<%=\"\"+currentTime.get(Calendar.DAY_OF_MONTH)%>">
								<%
								for (int i = 0; i < 31; i++)
								{%>
									<html:option value="<%=\"\"+i%>"><%=i%></html:option>
								<%}%>
							</html:select>
						</td>
						<td>
							<html:select name="ReservationForm" property="endYear" value="<%=\"\"+currentTime.get(Calendar.YEAR)%>">
								<%
								for (int i = 0; i < 5; i++)
								{%>
									<html:option value="<%=\"\"+(currentTime.get(Calendar.YEAR)+i)%>"><%=(currentTime.get(Calendar.YEAR)+i)%></html:option>
								<%}%>
							</html:select>
						</td>
					</table>
					</td>
				</tr>
				<tr>
					<td align="right">
						<html:submit value="Submit"/>
					</td>
					<td>
						<html:cancel value="Back"/>
					</td>
				</tr>
			</table>
		</html:form>
	</body>
</HTML>